// =====================================================================================
// 
//       Filename:  main.cpp
// 
//    Description:  
// 
//        Version:  1.0
//        Created:  23.09.2011 14:07:28
//       Revision:  none
//       Compiler:  g++
// 
//         Author:  Dmitriy Serdyuk (), serdyuk.dmitriy@gmail.com
//        Company:  
// 
// =====================================================================================

#include <cstdio>
#include <cstring>

void merge_sort(char *c, int size, char *buffer) {
    if (size <= 1) {
        return; 
    }
    merge_sort(c, size / 2, buffer);
    merge_sort(c + size / 2, size - size / 2, buffer);
    int i = 0;
    int j = size / 2;
    int k = 0;
    while ((i < size / 2) || (j < size)) {
        if (i >= size / 2) {
            buffer[k] = c[j];
            ++j;
            ++k;
            continue;
        }
        if (j >= size) {
            buffer[k] = c[i];
            ++i;
            ++k;
            continue;
        }
        if (c[i] < c[j]) {
            buffer[k] = c[i];
            ++i;
        } else {
            buffer[k] = c[j];
            ++j;
        }
        ++k;
    }
    for (int i = 0; i < size; ++i) {
        c[i] = buffer[i];
    }
}


char *bin_search(char *begin, char *end, char letter) {
    if (end <= begin) {
        return 0;
    }
    char *center = begin + (end - begin) / 2;
    if (*center == letter) {
        return center;
    }
    if (*center > letter) {
        return bin_search(begin, center, letter);
    }
    if (*center > letter) {
        return bin_search(center, end, letter);
    }
}

int main(int argc, char *argv[]) {

    char *a;
    scanf("%s", a);
    int size = strlen(a);
    char *buffer = new char[size];
    merge_sort(a, size, buffer);
    for (int i = 0; i < size; ++i) {
        printf("%c", a[i]);
    }
    char *symb = bin_search(a, a + size - 1, '4');
    printf("\n%d\n", (int)(symb - a));
    
    return 0;
}

